<div class="mdui-card-header">
    <form id="queryForm">
        <div class="layui-inline" style="margin-left: -30px">
            <label class="layui-form-label">起始时间</label>
            <div class="layui-input-inline">
                <input type="text" autocomplete="OFF" class="layui-input" name="startTime" id="startTime" placeholder="yyyy-MM-dd HH:mm:ss" value="${(query.startTime)!}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">截止时间</label>
            <div class="layui-input-inline">
                <input type="text" autocomplete="OFF" class="layui-input" name="endTime" id="endTime" placeholder="yyyy-MM-dd HH:mm:ss" value="${(query.endTime)!}">
            </div>
        </div>
        <button type="button" id="queryBtn" class="ml10 mdui-btn mdui-btn-raised mdui-btn-dense mdui-btn-icon" title="搜索" onclick="query()"><i class="mdui-icon material-icons">&#xe8b6;</i></button>
    </form>
</div>
<div class="mdui-card-content">
    <div id="pie" style="width: 600px;height:400px;"></div>
    <div id="zhu" style="width: 600px;height:400px;"></div>

</div>

<script>
    layui.use(['laydate'], function() {
            var laydate = layui.laydate;
            //开始时间
            laydate.render({
                elem: '#startTime'
                ,type: 'datetime'
            });
            laydate.render({
                elem: '#endTime'
                ,type: 'datetime'
            });

        }
    );
    function query() {
        loadPost("flow/statistic", $("#queryForm").serialize(), "#myContent", true);
    }


    // 基于准备好的dom，初始化echarts实例
    var pie = echarts.init(document.getElementById('pie'));
    var zhu = echarts.init(document.getElementById('zhu'));

    pie.setOption({
        title: {
            text: '流量占比',
            subtext: '来源于抓包数据',
            left: 'center'
        },
        tooltip: {
            trigger: 'item',
            formatter: '{a} <br/>{b} : {c} ({d}%)'
        },
        legend: {
            orient: 'vertical',
            left: 'left',
            data: ['TCP', 'UDP', 'IP', 'ARP', 'ICMP']
        },
        series: [
            {
                name: '访问量',
                type: 'pie',
                radius: '55%',
                center: ['50%', '60%'],
                data: [
                    <#list data?keys as key>
                    {value: ${data["${key}"]},name: "${key}"},
                     </#list>
                ],
                emphasis: {
                    itemStyle: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            }
        ]
    });
    zhu.setOption( {
        color: ['#3398DB'],
        tooltip: {
            trigger: 'axis',
            axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
            }
        },
        grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            containLabel: true
        },
        xAxis: [
            {
                type: 'category',
                data: ['TCP', 'UDP', 'IP', 'ARP', 'ICMP'],
                axisTick: {
                    alignWithLabel: true
                }
            }
        ],
        yAxis: [
            {
                type: 'value'
            }
        ],
        series: [
            {
                name: '访问量',
                type: 'bar',
                barWidth: '60%',
                data: [${data["TCP"]}, ${data["UDP"]}, ${data["IP"]}, ${data["ARP"]}, ${data["ICMP"]}]
            }
        ]
    });



</script>
